<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Repeating element</title>
    <style>
        @page {
            size: 820px;
        }
        @-epubx-page-template {
            .partition {
                width: 198px;
                height: 398px;
                border: rgba(0, 0, 255, 0.2) solid 1px;
                -epubx-flow-from: body;
                writing-mode: vertical-rl;
            }
            .left {
                top: 10px;
            }
            .right {
                bottom: 10px;
            }

            @-epubx-page-master {
                @-epubx-partition {
                    bottom: 0;
                    left: 0;
                    right: 0;
                    height: 10px;
                    font-size: 10px;
                    line-height: 10px;
                    text-align: center;
                    content: counter(page);
                }
                @-epubx-partition class(partition) class(right) {
                    right: 610px;
                }
                @-epubx-partition class(partition) class(right) {
                    right: 410px;
                }
                @-epubx-partition class(partition) class(right) {
                    right: 210px;
                }
                @-epubx-partition class(partition) class(right) {
                    right: 10px;
                }
                @-epubx-partition class(partition) class(left) {
                    right: 610px;
                }
                @-epubx-partition class(partition) class(left) {
                    right: 410px;
                }
                @-epubx-partition class(partition) class(left) {
                    right: 210px;
                }
                @-epubx-partition class(partition) class(left) {
                    right: 10px;
                }
            }
        }
        :root {
            writing-mode: vertical-rl;
            font-size: 10px;
            line-height: 12px;
            widows: 1;
            orphans: 1;
        }
        body {
            margin: 10px 0;
        }
        section {
            break-after: column;
        }
        h1 {
          font-size: 10px;
          font-weight: normal;
        }

        .header {
            repeat-on-break: header;
            background-color: #FF9999 !important;
        }
        .footer {
            repeat-on-break: footer;
            background-color: #9999FF !important;
        }

        .auto {
            repeat-on-break: auto;
        }
        .thead {
            display: table-header-group;
        }
        .tfoot {
            display: table-footer-group;
        }

        .box {
            width: 30px;
            border: 1px solid #999;
            margin: 2px;
            padding: 2px;
        }
        .child {
            padding: 10px;
            margin: 2px;
            border: 1px solid #999;
            background-color: #ddd;
        }
        .child .box {
            background-color: #FFF;
            width: 20px;
        }
    </style>
</head>
<body>


<section>
    <h1>(1) header/footer is in the first child element</h1>
    <div>
        <div class="box header">this is header</div>
        <div class="box footer">this is footer</div>
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
        <div class="box">4</div>
        <div class="box">5</div>
        <div class="box">6</div>
        <div class="box">7</div>
        <div class="box">8</div>
        <div class="box">9</div>
    </div>
</section>

<section>
    <h1>(2) header/footer is in the last child element</h1>
    <div>
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
        <div class="box">4</div>
        <div class="box">5</div>
        <div class="box">6</div>
        <div class="box">7</div>
        <div class="box">8</div>
        <div class="box">9</div>
        <div class="box header">this is header</div>
        <div class="box footer">this is footer</div>
    </div>
</section>

<section>
    <h1>(3) If there are multiple headers/footers, only the first one is used</h1>
    <div>
        <div class="box header">this is header</div>
        <div class="box footer">this is footer</div>
        <div class="box header">this header treated as an ordinary element</div>
        <div class="box footer">this footer treated as an ordinary element</div>
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
        <div class="box">4</div>
        <div class="box">5</div>
        <div class="box">6</div>
        <div class="box">7</div>
        <div class="box">8</div>
        <div class="box">9</div>
        <div class="box header">this header treated as an ordinary element</div>
        <div class="box footer">this footer treated as an ordinary element</div>
    </div>
</section>


<section>
    <h1>(4) drop header/footers if no enough space</h1>
    <div>
        <div class="box header">this is header of parent</div>
        <div class="box footer">this is footer of parent</div>
        <div class="box" style="width:50px">
          content width=50px;
        </div>
        <div class="box" style="width:140px">
          content width=140px;
        </div>
        <div class="box" style="width:200px">
          content width=200px;
        </div>
        <div class="box" style="width:50px">
          content width=50px;
        </div>
    </div>
</section>

<section>
    <h1>(5) tall footer</h1>
    <div>
        <div class="box header">this is header of parent</div>
        <div class="box footer" style="width:140px">this is footer of parent</div>
        <div class="box">content 1</div>
        <div class="box">content 2</div>
        <div class="box">content 3</div>
    </div>
</section>

<section>
    <h1>(6) tall header</h1>
    <div>
        <div class="box header" style="width:125px">this is header of parent</div>
        <div class="box footer">this is footer of parent</div>
        <div class="box">content 1</div>
        <div class="box">content 2</div>
        <div class="box">content 3</div>
    </div>
</section>

<section>
    <h1>(7) tall header/footer</h1>
    <div>
        <div class="box header" style="width:140px">this is header of parent</div>
        <div class="box footer" style="width:140px">this is footer of parent</div>
        <div class="box">content 1</div>
        <div class="box">content 2</div>
        <div class="box">content 3</div>
    </div>
</section>


</body>
</html>
